/*
 * BoardCell.java
 *
 * Created on 11 ספטמבר 2009, 21:49
 */

package gomoku;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Graphics2D;


public class BoardCell extends javax.swing.JPanel  {
    boolean isEmpty;
    boolean isBoarder;
    Color bgColor;
    int col,row;


    /** Creates new form BoardCell */
    public BoardCell(boolean boarder, int c, int r) {
        isEmpty = true;
        isBoarder = boarder;
        col = c;
        row = r;
        initComponents();
    }

    public void setBgColor(Color c)
    {
        bgColor = c;
    }
    public void  clearCell() {
        isEmpty = true;
    }
    
    @Override 
    protected  void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.setColor(bgColor);
        g.fillRect(0,0,getWidth(), getHeight());
        
        
         
        if (isBoarder && (col != 0 ||  row != 0)) {
            if (col != 0) {
                g.setColor(Color.WHITE);
                g.drawString(String.format("%c",'A'-1+col),getWidth()/3,getHeight()/2);                
            } else {
                g.setColor(Color.WHITE);
                g.drawString(String.format("%d",row),getWidth()/3,getHeight()/2);                
            }
        }

   
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        setFocusable(false);
        setMaximumSize(new java.awt.Dimension(30, 30));
        setName("Form"); // NOI18N
        setPreferredSize(new java.awt.Dimension(30, 30));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 28, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 28, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

}
